package com.storydo.db.view.gui;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Locale;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTree;

import com.storydo.db.view.util.LocaleUtils;

/**   
* @Title: MainFrame.java 
* @Description: TODO
* @author : Storydo
* @date: 2021年9月15日 下午3:19:08 
* @version:V1.0 
* Copyright 悦享互联 2016 All right reserved.
* Modification  History:
* Version       Date          Author          Description
* ----------------------------------------------------------------------------
*  1.0         2021年9月15日        Storydo              TODO
*/

public class MainFrame extends JFrame implements ActionListener {

	private static final long serialVersionUID = 1L;
	
	private static MainFrame mainFrame;
	
	private JScrollPane contentPanel;

    private JScrollPane treePanel;

    private JTree tree;
	
    
    public static MainFrame getInstance() {
    	if (mainFrame == null) {
			mainFrame = new MainFrame();
		}
    	return mainFrame;
    }
    
    
	private MainFrame() {
		super();
		this.setTitle(LocaleUtils.getResString("main_frame_title"));
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		initUI();
	}

	private void initUI() {
		JPanel main = new JPanel(new BorderLayout());
		JSplitPane treeAndContent = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
		treePanel = createTreePanel();
		treeAndContent.setLeftComponent(treePanel);
		
		contentPanel = createContentPanel();
		treeAndContent.setRightComponent(contentPanel);
		
		main.add(treeAndContent);
		getContentPane().add(main);
	}
	
	private JScrollPane createTreePanel() {
        JScrollPane treeP = new JScrollPane(tree);
        treeP.setMinimumSize(new Dimension(100, 0));
        return treeP;
    }
	
	private JScrollPane createContentPanel() {
        return new JScrollPane();
    }
	
	@Override
	public void actionPerformed(ActionEvent e) {
		LocaleUtils.setLocale(Locale.ENGLISH);
		
	}

}
